package enterprise.web_jpa_war.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author Thomas
 */
@Entity
@NamedQueries({
   @NamedQuery(name="getTypesMatchName",
               query="SELECT t FROM Type t WHERE t.typeName = :typeName")
})
public class Type implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Column(name = "TYPENAME")
    private String typeName;
    
    @Column(name = "DUREEMAXEMPRUNT")
    private Integer dureeMaxEmprunt;

    public Type() {
    }

    public Type(String typeName, Integer dureeMaxEmprunt) {
        this.typeName = typeName.toUpperCase();
        this.dureeMaxEmprunt = dureeMaxEmprunt;
    }
    
    public Integer getDureeMaxEmprunt() {
        return dureeMaxEmprunt;
    }

    public void setDureeMaxEmprunt(Integer dureeMaxEmprunt) {
        this.dureeMaxEmprunt = dureeMaxEmprunt;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (typeName != null ? typeName.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Type)) {
            return false;
        }
        Type other = (Type) object;
        if ((this.typeName == null && other.typeName != null) || (this.typeName != null && !this.typeName.equals(other.typeName))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "enterprise.web_jpa_war.entity.Type[ id=" + typeName + " ]";
    }
    
}
